package shujia.day03;

/*
    一维数组的静态初始化
    语句定义格式：
        数据类型[] 数组名 = new 数据类型[]{元素1,元素2,.....};
 */
public class ArrayDemo4 {
    public static void main(String[] args) {
//        int[] arr1 = new int[]{11,22,33,44,55};
//        int[] arr1;
//        arr1 = new int[]{11,22,33,44,55};
        int[] arr1 = new int[]{11,22,33,44,55};
        System.out.println(arr1);
        System.out.println(arr1[0]);
        System.out.println(arr1[1]);
        System.out.println(arr1[2]);
        System.out.println(arr1[3]);
        System.out.println(arr1[4]);

        /**
         *  静态初始化的简化写法
         */
        int[] arr2 = {100,200,300,400,500,600};
//        int[] arr2;
//        arr2 = {100,200,300,400,500,600}; // 简化写法不允许将定义和初始化分开两行写
        System.out.println(arr2);
        System.out.println(arr2[0]);
        System.out.println(arr2[1]);
        System.out.println(arr2[2]);
        System.out.println(arr2[3]);
        System.out.println(arr2[4]);
        System.out.println(arr2[5]);
    }
}
